home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / slix0987.zip / RAW100.ZIP / RAW100.BAS < prev    next >
BASIC Source File  |  1996-05-20  |  3KB  |  98 lines

  1. 'RAW100.BAS
  2. '
  3. 'RAW file converter 1.00 -- written by Lloyd Chang
  4. '
  5. 'purpose: Converts a 24 bit (truecolor) RAW file
  6. '         into a 8 bit (256 colors) RAW file
  7. '         with the RGB palette created by RGB100.BAS
  8. '             
  9. 'lingo: 24 bit = 16,400,000 (16.4 million)
  10. '       8 bit = 256
  11. '       RAW file = A file without a header.
  12. '                  It contains only data.
  13. '
  14. 'note: 24 bit RAW file uses 3 bytes per pixel.
  15. '      Each byte of the 3 bytes contains either
  16. '      the red, green, or blue component of the pixel.
  17. '
  18. 'note: 8 bit RAW file uses 1 byte per pixel.
  19. '      Therefore, it requires a palette to properly
  20. '      display the colors.  In RAW-256.BAS, the RGB
  21. '      palette created by RGB100.BAS is used.
  22. '
  23. 'note: Scaling is not supported.
  24. '
  25. 'note: Color dithering is not supported either.
  26. '
  27. 'note: The user of this program has to know the
  28. '      horizontal and vertical size of the 24 bit
  29. '      RAW file beforehand.
  30. '
  31. 'note: An error might occur when this program is
  32. '      used in the QuickBasic Environment.
  33. '      Try using RAW100.EXE or recompiling RAW100.BAS
  34. '
  35. 'files that should accompany this program: ASTRNAUT.24
  36. '                                          ASTRNAUT.8
  37. '                                          ASTRNAUT.JPG
  38. '                                          BRUN45.EXE
  39. '                                          FILE_ID.DIZ
  40. '                                          INDEX.TXT
  41. '                                          RAW100.EXE
  42. '                                          RGB.PAL
  43. '                                          RGB100.BAS
  44. '                                          SEE8-100.BAS
  45. '
  46. DEFINT A-Z
  47. colors$ = SPACE$(3 * 10922)
  48. PaletteRGB$ = SPACE$(768)
  49. PRINT "RAW file converter 1.00"
  50. INPUT "Filename to load: ", filein$
  51. OPEN filein$ FOR BINARY AS #1
  52. INPUT "Filename to write: ", fileout$
  53. OPEN fileout$ FOR BINARY AS #2
  54. OPEN "RGB.PAL" FOR BINARY AS #3
  55. GET #3, 1, PaletteRGB$
  56. PRINT
  57. PRINT " In Byte:"
  58. PRINT "Out Byte:"
  59. DO
  60.   GET #1, , colors$
  61.   UseColor$ = ""
  62.   ByteCountEnd% = (LEN(colors$) \ 3)
  63.   FOR ByteCount% = 1 TO ByteCountEnd%
  64.     FirstColor$ = MID$(colors$, (((ByteCount% - 1) * 3) + 1), 1)
  65.     SecondColor$ = MID$(colors$, (((ByteCount% - 1) * 3) + 2), 1)
  66.     ThirdColor$ = MID$(colors$, (((ByteCount% - 1) * 3) + 3), 1)
  67.     Blue% = (ASC(FirstColor$) \ 36)
  68.     Green% = (ASC(SecondColor$) \ 84)
  69.     Red% = (ASC(ThirdColor$) \ 36)
  70.     FOR Count% = 0 TO 255
  71.       SELECT CASE (ASC(MID$(PaletteRGB$, ((Count% * 3) + 1), 1)) \ 36)
  72.         CASE IS = Blue%
  73.           SELECT CASE (ASC(MID$(PaletteRGB$, ((Count% * 3) + 2), 1)) \ 84)
  74.             CASE IS = Green%
  75.               SELECT CASE (ASC(MID$(PaletteRGB$, ((Count% * 3) + 3), 1)) \ 36)
  76.                 CASE IS = Red%
  77.                   UseColor$ = UseColor$ + CHR$(Count%)
  78.               END SELECT
  79.           END SELECT
  80.       END SELECT
  81.     NEXT Count%
  82.     InCount& = (Counter& * LEN(colors$)) + (ByteCount% * 3)
  83.     OutCount& = (Counter& * ByteCountEnd%) + LEN(UseColor$)
  84.     LOCATE (CSRLIN - 2), 10
  85.     PRINT STR$(InCount&)
  86.     LOCATE , 10
  87.     PRINT STR$(OutCount&)
  88.     SELECT CASE InCount&
  89.       CASE IS >= LOF(1)
  90.         EXIT FOR
  91.     END SELECT
  92.   NEXT ByteCount%
  93.   PUT #2, , UseColor$
  94.   Counter& = Counter& + 1
  95. LOOP UNTIL EOF(1)
  96. CLOSE #1, #2, #3
  97.  
  98.